package com.mingqijia.gassafety.shared.utils;

import com.alibaba.druid.util.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import javax.servlet.http.HttpServletRequest;

@Component
@Slf4j
public class HeaderUtil {

    public Integer getTemplateType() {
        ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
        HttpServletRequest request = servletRequestAttributes.getRequest();
        String templateType = request.getHeader("templateType");
        if (StringUtils.isEmpty(templateType)) {
            templateType = "0";
        }
        log.info("页面展示模板:" + templateType);
        return Integer.valueOf(templateType);
    }

}